﻿namespace WMS6.Web.Configuration
{
    using System;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;

    public class SKUQuery : BasePage
    {
        protected Button btnExport;
        protected Button btnList;
        protected Button btnNew;
        protected Button btnSearch;
        protected DropDownList ddlIsActive;
        protected DropDownList ddlIsActiveOper;
        protected DropDownList ddlLotTemplateID;
        protected DropDownList ddlOwnerIDOper;
        protected DropDownList ddlPackID;
        protected DropDownList ddlSkuClassID;
        protected DropDownList ddlSkuDescrOper;
        protected DropDownList ddlSkuIDOper;
        protected HtmlForm F2060;
        protected HtmlInputHidden hdnActionID;
        protected HtmlInputHidden hdnType;
        protected Label lblIsActive;
        protected Label lblLotTemplateID;
        protected Label lblOwnerID;
        protected Label lblPackID;
        protected Label lblSku;
        protected Label lblSkuClassID;
        protected Label lblSkuDescr;
        protected Label lblSkuID;
        protected HtmlLink mycss;
        protected ScriptManager ScriptManager1;
        protected HtmlTableRow trOwnerID;
        protected HtmlTableRow trtxtOwnerID;
        protected TextBox txtLotTemplateID;
        protected TextBox txtOwnerID;
        protected TextBox txtPackID;
        protected TextBox txtSkuClassID;
        protected TextBox txtSkuDescr;
        protected TextBox txtSkuID;

        protected void btnList_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("SkuList.aspx?action={0}&ownerID={1}&from=list&type={2}&ckb={3}&OnLine={4}", new object[] { base.UrlEncode(this.hdnActionID.Value.Trim()), base.UrlEncode(this.txtOwnerID.Text.Trim()), base.Request.QueryString["type"], base.Request.QueryString["ckb"], base.Request.QueryString["OnLine"] }), false);
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("SkuList.aspx?action={0}&ownerID={1}&type={2}&ckb={3}&OnLine={4}", new object[] { base.UrlEncode(this.hdnActionID.Value.Trim()), base.UrlEncode(this.txtOwnerID.Text.Trim()), base.Request.QueryString["type"], base.Request.QueryString["ckb"], base.Request.QueryString["OnLine"] }), false);
        }

        private void InitDropDownLists()
        {
            base.InitQueryDDL(this.ddlSkuIDOper, 0);
            base.InitQueryDDL(this.ddlOwnerIDOper, 0);
            base.InitQueryDDL(this.ddlSkuDescrOper, 0);
            base.InitQueryDDL(this.ddlIsActiveOper, 0);
            base.InitQueryDDL(this.ddlPackID, 0);
            base.InitQueryDDL(this.ddlLotTemplateID, 0);
            base.InitQueryDDL(this.ddlSkuClassID, 0);
            base.InitIsActiveDDL(this.ddlIsActive, 0);
        }

        private void LoadData()
        {
            if (!string.IsNullOrEmpty(base.Request.QueryString["action"]))
            {
                this.btnNew.Visible = false;
                this.btnExport.Visible = false;
                if (!string.IsNullOrEmpty(base.Request.QueryString["ownerID"]))
                {
                    this.txtOwnerID.Text = base.Request.QueryString["ownerID"];
                    this.txtOwnerID.Enabled = false;
                    this.ddlOwnerIDOper.Enabled = false;
                }
                if (!string.IsNullOrEmpty(base.Request.QueryString["OnLine"]))
                {
                    this.ddlOwnerIDOper.SelectedValue = "One Of";
                }
                this.ddlIsActive.SelectedValue = "Y";
                this.ddlIsActive.Enabled = false;
                if (!string.IsNullOrEmpty(base.Request.QueryString["ckb"]) && (base.Request.QueryString["ckb"] != "N"))
                {
                    this.hdnActionID.Value = base.Request.QueryString["action"];
                    this.btnSearch_Click(null, null);
                }
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                base.InitPage(this.Page);
                this.InitDropDownLists();
                this.LoadData();
            }
        }

        public string IsActive
        {
            get
            {
                if (!string.IsNullOrEmpty(this.ddlIsActive.SelectedValue))
                {
                    return base.GetParamsString(this.ddlIsActive.SelectedValue, this.ddlIsActiveOper.SelectedValue);
                }
                return "";
            }
        }

        public string LotTemplateID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtLotTemplateID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtLotTemplateID.Text.Trim(), this.ddlLotTemplateID.SelectedValue);
                }
                return "";
            }
        }

        public string OwnerID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtOwnerID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtOwnerID.Text.Trim(), this.ddlOwnerIDOper.SelectedValue);
                }
                return "";
            }
        }

        public string PackID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtPackID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtPackID.Text.Trim(), this.ddlPackID.SelectedValue);
                }
                return "";
            }
        }

        public string SkuClassID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtSkuClassID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtSkuClassID.Text.Trim(), this.ddlSkuClassID.SelectedValue);
                }
                return "";
            }
        }

        public string SkuDescr
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtSkuDescr.Text.Trim()))
                {
                    return base.GetParamsString(this.txtSkuDescr.Text.Trim(), this.ddlSkuDescrOper.SelectedValue);
                }
                return "";
            }
        }

        public string SkuID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtSkuID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtSkuID.Text.Trim(), this.ddlSkuIDOper.SelectedValue);
                }
                return "";
            }
        }
    }
}

